package RabbitMQ.Simple;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.TimeoutException;
public class ProducerDemo {
public static void main(String[] args) throws IOException, TimeoutException {
    ConnectionFactory connectionFactory=new ConnectionFactory();
    connectionFactory.setHost("203.33.207.200");
    connectionFactory.setPort(5672);
    connectionFactory.setUsername("shiyu");
    connectionFactory.setPassword("shiyu");
    connectionFactory.setVirtualHost("maqiu");
    Connection connection=connectionFactory.newConnection();
    Channel channel=connection.createChannel();
    channel.queueDeclare("hello",true,false,false,null);
    String message="hello,RabbitMQ";
    channel.basicPublish("","hello",null,message.getBytes(StandardCharsets.UTF_8) );
    System.out.println("已经连接到RabbitMQ");
    channel.close();
    connection.close();
}

}
